package Homework3;

import java.util.Scanner;

public class Homework3_4 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = input.nextInt();
        }
        int[][] b = new int[n][];
        for (int i = 0; i < n; i++) {
            b[i] = new int[a[i]];
        }
        int n2 = n * n;
        for (int i = 0; i < n; i++) {
            for (int j = a[i] - 1; j >= 0; j--){
                b[i][j] = n2;
                n2--;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < a[i]; j++){
                System.out.print(b[i][j] + " ");
                if (j == a[i] - 1) {
                    System.out.println();
                }
            }
        }

    }
}
